﻿using AudioStudio;
using UnityEngine;

public class PlaySoundWhenShow : MonoBehaviour
{
    [SerializeField] private bool playOnce = false;

    [SerializeField] private string soundName;

    private int playCount = 0;

    private void OnEnable()
    {
        if (string.IsNullOrEmpty(this.soundName) || (this.playOnce && this.playCount > 0))
            return;
        
        AudioManager.PlayVoice(this.soundName);
        this.playCount++;
    }
}
